<script>
import { defineComponent, inject } from 'vue'
import { useRouter } from 'vue-router'
import * as mars3d from 'mars3d'
export default defineComponent({
  setup () {
    const router = useRouter()
    const viewer = inject('vumViewer')
    const map = new mars3d.Map(viewer)
    const measure = new mars3d.thing.Measure({
      label: {
        color: '#ffffff',
        font_family: '楷体',
        font_size: 20,
        background: false,
      },
    })
    map.addThing(measure)
    const removeAll = () => {
      measure.clear()
    }

    return {
      measure,
      removeAll,
    }
  },
})
</script>
<template>
  <div class="measure-box" style="display: flex;">
    <div class="measure-item flex-row-center-center" @click="$router.push('/map')">
      <div class="measure-100 measure-button-right" sk-flex="row-around-center">
        <span class="measure-button">全屏</span>
      </div>
    </div>
    <div class="measure-item flex-row-center-center">
      <div @click="measure.distance({ showAddText: true })"
        class="measure-100 measure-button-middle flex-row-center-center" sk-flex="row-around-center">
        <span class="measure-button">测距</span>
      </div>
    </div>
    <div class="measure-item flex-row-center-center" @click="measure.area({})">
      <span class="measure-button">测面</span>
    </div>
  </div>
</template>
<style lang='scss' scoped>
.measure-box {
  color: black;
  position: absolute;
  width: 12em;
  height: 2em;
  right: 5em;
  top: 0.5em;
  z-index: 2;
  background: white;
}

.measure-button {
  font-size: 14px;
  display: inline-block;
  width: 2.8em;
  height: 1.6em;
  text-align: center;
  line-height: 1.6em;
  border-radius: 2px;
  cursor: pointer;
}

.measure-item {
  flex: 1;
  color: black;

  &:hover {
    color: rgb(179, 171, 171);
  }
}

.measure-icon {
  width: 1.5em;
  height: 1.5em;
  cursor: pointer;
}

.measure-100 {
  height: 60%;
  width: 100%;
}

.measure-button-middle {
  border-right: 1px solid black;
}

.measure-button-right {
  border-right: 1px solid black;
  padding-left: 5px;
}

.flex-row-center-center {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>